package com.dfbz.demo01_多态案例引入;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {
    public static void main(String[] args) {

        PetStore petStore=new PetStore();

        Dog dog=new Dog();
//        petStore.storeDog(dog);
        petStore.storeAnimal(dog);          // 多态的体现

        Cat cat = new Cat();
        petStore.storeAnimal(cat);
//        petStore.storeCat(cat);

    }
}

// 宠物店
class PetStore {


    public void storeAnimal(Animal animal){
        animal.eat();
        animal.sleep();
        System.out.println("寄存了一只动物.....");
        System.out.println("--------------");
    }

    public void storeDog(Dog dog) {
        dog.eat();
        dog.sleep();
        System.out.println("寄存了一只狗....");
        System.out.println("--------------");
    }

    public void storeCat(Cat cat){
        cat.eat();
        cat.sleep();
        System.out.println("寄存了一只猫....");
        System.out.println("--------------");
    }
}


class Animal{
    public void eat() {
        System.out.println("吃饭..");
    }

    public void sleep() {
        System.out.println("睡觉..");
    }
}

class Cat extends Animal{

}

class Dog extends Animal {

}

